package first;

import java.util.ArrayList;
import java.util.List;

import first.liter.Literature;
import first.liter.Literature.LITERATURE;


/**
 * 
 * @version Wed Oct 20,2010
 * @author Kozlov Kirill
 *
 */
public class Catalogue {
	
	//public enum LITERATURE { BOOK, JOURNAL };
	/**
	 * List of literature in current catalogue
	 */
	private List<Literature> listLiterature;
	
	
	/**
	 * Name of current catalogue
	 */
	private String nameCatalogue;
	
	/**
	 * Description of current Catalogue;
	 */
	private String descriptionCatalogue;
	
	/**
	 * Amount of Books in current catalogue
	 */
	private int amountOfBooks;
	
	/**
	 * Amount of Journals in current catalogue	
	 */
	private int amountOfJournals;

//===================================================================================================
	
	
	/**
	 *  Constructor for library catague
	 */
	public Catalogue()
	{
		this.setNameCatalogue("default");
		this.setDescriptionCatalogue("default");
		this.listLiterature=new ArrayList<Literature>();
		this.amountOfBooks=0;
		this.amountOfJournals=0;
	}
	
//===================================================================================================

	/**
	 * Method that adds {@link Literature} to catalogue
	 * @param lit current literature that you want to add to catalogue
	 */
	public void addLiterature(Literature lit)
	{
		this.listLiterature.add(lit);
		
		LITERATURE tp=LITERATURE.valueOf(lit.getTypeOfLiterature().toUpperCase());
		switch(tp)
		{
		case BOOK:this.amountOfBooks++;
		case JOURNAL:this.amountOfJournals++;
		default:{}
		}
	}

	/**
	 * Method that deletes {@link Literature} from catalogue
	 * @param lit current literature that you want to delete from catalogue
	 */
	public void deleteLiterature(Literature lit)
	{
		//Literature t=new //this.listLiterature.remove(this.findNumberLiterature(lit));
	}
	
	/**
	 * Metod that returns the number in the catalogue  of current literature
	 * @param lit current {@link Literature} that you want to find in catalogue
	 * @return the number in the catalogue  of current literature
	 */
	public int findNumberLiterature(Literature lit)
	{
		int num=0;
		
		for(int i=0;i<this.getAmountOfLiterature();i++)
		{
			//this.listLiterature[i].e
		}
		
		return num;
	}
	
	public int amountOfText()
	{
		int summ=0;
		System.out.println(listLiterature.size());
		for(Literature e:listLiterature)
		{
			summ+=e.getAmountOfPages();
			System.out.println(e.getAmountOfPages());
		}
		return summ;
	}
	
//=======================================================================================================
	/**
	 * Method sets the name of catalogue
	 * @param nameCatalogue the nameCatalogue to set
	 */
	public void setNameCatalogue(String nameCatalogue) 
	{
		this.nameCatalogue = nameCatalogue;
	}

	/**
	 * Metod returns the name of current catalogue
	 * @return nameCatalogue
	 */
	public String getNameCatalogue() 
	{
		return nameCatalogue;
	}

	/**
	 * @param descriptionCatalogue the descriptionCatalogue to set
	 */
	public void setDescriptionCatalogue(String descriptionCatalogue) {
		this.descriptionCatalogue = descriptionCatalogue;
	}

	/**
	 * @return the descriptionCatalogue
	 */
	public String getDescriptionCatalogue() {
		return descriptionCatalogue;
	}



	/**
	 * @return the amountOfBooks
	 */
	public int getAmountOfBooks() {
		return amountOfBooks;
	}

	
	/**
	 * @return the amountOfJournals
	 */
	public int getAmountOfJournals() {
		return amountOfJournals;
	}
	
	/**
	 * 
	 * @return amount of {@link Literature} in catalogue
	 */
	public int getAmountOfLiterature()
	{
		return this.amountOfBooks+this.amountOfJournals;
	}
	
		
}
